home *** CD-ROM | disk | FTP | other *** search
/ AM/FM: Amiga Musicians' Freeware Magazine 1 / AM-FM 1.adf / TechCorner / example1.c < prev    next >
C/C++ Source or Header  |  1991-10-03  |  1KB  |  35 lines

  1. /* Example of using the 'midiroutines.a' from a C-language program */
  2. /* Written by Teijo Kinnunen. */
  3.  
  4. /* linking info:
  5. blink from lib:c.o+example1.o+midiroutines.o to example1 lib lib:lc.lib ND
  6. */
  7.  
  8. /* This simple example plays a C major chord using MIDI channel 1 */
  9.  
  10. #include "midiroutines.h"
  11. #include <proto/dos.h>    /* eliminate the need of amiga.lib */
  12.  
  13. /* This is the Note On data we will send. We use separate Note On
  14.    command (0x90) for each note to demonstrate that the automatic
  15.    rsb-optimization really works. */
  16. static UBYTE ondata[] = { 0x90,0x3c,0x40,0x90,0x40,0x40,0x90,0x43,0x40 };
  17. /* And the Note Off data respectively. */
  18. static UBYTE offdata[] = { 0x80,0x3c,0x40,0x80,0x40,0x40,0x80,0x43,0x40 };
  19.  
  20. void main()
  21. {
  22.     LONG fail;
  23.     fail = GetSerial();
  24.     if(fail) printf("Can't allocate serial port!\n");
  25.     else {
  26.         printf("Playing C Major chord...");
  27.         AddMIDIData(ondata,9); /* length = 9 bytes */
  28.         Delay(50); /* wait for about 1 second */
  29.         AddMIDIData(offdata,9); /* turn off the notes */
  30.         Delay(5); /* small pause for sending the note off msgs */
  31.         printf("done.\n");
  32.         FreeSerial();
  33.     }
  34. }
  35.